package acm.pta8;

import java.util.Scanner;

public class Wifi密码 {
    /**
     * 思路：找到正确答案对应的选项，用其减去ascii码该题答案顺序
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        while (n-- > 0) {
            System.out.print(get(sc.nextLine()));
        }
    }
    public static int get(String line){
        int i = line.indexOf("T");
        int res=line.charAt(i-2)-64;
        return res;
    }
//    static {
//        System.out.println(get("C-T Hello-F B-F D-F"));
//    }
}
